package frontend.login.controller;
import java.util.Map;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ActionContext;

import core.discount.model.Coupon;
import core.profile.model.BasicCredential;
import frontend.registration.dao.RegisterDao;
import frontend.user.controller.GetDataByEmailId;
public class LoignDisableFlag extends ActionSupport {
	/**
	 * 
	 */
	private static final long serialVersionUID = -1948643569906507370L;
	private int disabledflag=0;
	private boolean used=true;
	private BasicCredential basicCredential;
	private Coupon coupon;	
	public String execute() throws Exception{
	  RegisterDao rd =new RegisterDao();
	  Map<String, Object> session = ActionContext.getContext().getSession();
	  basicCredential=GetDataByEmailId.getBasicCredentialByUserId(session.get("emailId").toString());
	  basicCredential.setDisabledflag(disabledflag);
	  if(session.get("couponCode")!=null){
		  coupon=GetDataByEmailId.getCouponByCouponCode(session.get("cuoponCode").toString());
		  coupon.setUsed(used);
	  }
	  	rd.setCoupenFlag(coupon);
		rd.setDisableFlag(basicCredential);
		session.remove("cuoponCode");
		session.remove("emailId");
		session.remove("logined");
		Double amount= (Double) session.get("amount");
		Integer response= (Integer) session.get("response");
		String transactionid= (String) session.get("transactionid");
		
		basicaddress=getdatabyemailid.getBasicAddressByEmailId(session1);
		basicprofile=getdatabyemailid.getBasicProfileByEmailId(session1);
		
		paymenthistory.setAddress_1(basicaddress.getAddressLine1());
		paymenthistory.setAddress_2(basicaddress.getAddressLine2());
		paymenthistory.setAmount(amount);
		paymenthistory.setCity(basicaddress.getCity().getCityName());
		paymenthistory.setCompany(basicaddress.getCompanyname());
		paymenthistory.setCountry(basicaddress.getCountry().getCountryName());
		paymenthistory.setEmail(basicaddress.getEmail());
		paymenthistory.setFirst_name(basicaddress.getFirstname());
		paymenthistory.setLast_name(basicaddress.getLastname());
		paymenthistory.setPhone(basicaddress.getPhone());
		paymenthistory.setPostal_code(Long.parseLong(basicaddress.getPostalcode()));
		//paymenthistory.setProduct(product);
		paymenthistory.setResponse(response);
		paymenthistory.setState(basicaddress.getState().getStateName());
		paymenthistory.setTransactionid(transactionid);
		paymenthistory.setUser(basicprofile);
		return SUCCESS;
	}
}
